package com.shiliao.app.activity.personal.presenter;

import android.text.TextUtils;

import com.shiliao.app.activity.personal.service.IContributionNumberService;
import com.shiliao.app.activity.personal.service.impl.ContributionNumberImpl;
import com.shiliao.app.activity.personal.view.ContributionNumberView;
import com.shiliao.app.utils.YMServerUtil;
import com.yimei.framework.mvp.presenter.IBasePresenter;
import com.yimei.framework.network.ICallBack;
import com.yimei.framework.util.LogUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by yinzhiqiang on 2018/3/28.
 */

public class ContributionNumberPresenter extends IBasePresenter<IContributionNumberService> {
    private ContributionNumberView view;
    private IContributionNumberService service;

    public ContributionNumberPresenter(ContributionNumberView view) {
        this.view = view;
        service = new ContributionNumberImpl();
        setService(service);
    }

    public void request(String userId) {
        Map map = new HashMap();
        if (!TextUtils.isEmpty(userId)) {
            map.put("user_id", userId);
        }
        service.requestContribution(YMServerUtil.ACTION_CONTRIBUTION_NUMBER, map, new ICallBack() {
            @Override
            public void onSuccess(int statusCode, Object result) {
                LogUtil.e("yzq", result.toString());
                view.getTextContent(result.toString());
            }

            @Override
            public void onFail(int statusCode, Object result) {
                LogUtil.e("yzq", result.toString());
                view.getTextContent(result.toString());
            }
        });
    }

}
